<template>
  <basic-container>
    <avue-crud
      :data="tableDatas"
      :option="tableOption"
      :table-loading="tableLoading"
      @on-load="onLoad"
      @refresh-change="onLoad"
    >
      <template slot="menuLeft">
        <el-button @click="$router.back()" icon="el-icon-back" type="text" size="small">返回</el-button>
      </template>
      <template slot="dataBaseName" slot-scope="scope">
        <el-link type="primary" :href="'#/dws/dataread/table/' + scope.row.dataBaseId + '?guid=' + scope.row.guid">{{scope.row.dataBaseName}}</el-link>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
import {
  queryDataBaseByDataReadId
} from "@/api/dws/dataread";
export default {
  data(){
    return {
      dataModelId: this.$router.currentRoute.params.id,
      tableDatas: [],
      tableLoading: false,
      tableOption: {
        menu:false,
        addBtn:false,
        editBtn:false,
        delBtn:false,
        column:[
          {
            label:'库名称',
            prop:'dataBaseName'
          },
          {
            label:'读取类型',
            prop:'structureType'
          }
        ]
      }
    }
  },
  methods: {
    onLoad(){
      let obj = {
        id: this.dataModelId
      };
      this.tableLoading = true;
      queryDataBaseByDataReadId(obj).then( res => {
        this.tableDatas = res['data']['data'];
        this.tableLoading = false;
      }).catch(() => {
        this.tableDatas = [];
        this.tableLoading = false;
      });
    }
  }
}
</script>
